package com.chlitina.store.modules.inventory.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.chlitina.store.common.persistence.BaseEntity;
import com.chlitina.store.modules.employee.entity.Employee;
import com.chlitina.store.modules.sys.entity.Store;

/**
 * 入库Entity
 * @author Songsong.XU
 * @version 2013-11-08
 */
@Entity
@Table(name = "store_inventory_in")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class StoreInventoryIn extends BaseEntity {
	public final static int RED_STATUS = 1;// 已冲红
	public final static int NORMAL_STATUS = 0; //正常入库
	public final static int IN_SYSTEM=0;//系统产品
	public final static int IN_SELF=1;//店面自营产品
	
	private static final long serialVersionUID = 1L;
	private Long id; 		// 入库单编号
	private Store store; // 门店编号
	private Employee employee;	// 入库操作员工
	private Date inDate;
	private int inProductChannel;//入库产品渠0： 系统产品,1： 店面自营产品	
	private int status;	//入库单状态 0： 正常入库 1： 已冲红
	private int amount;
	private String calcelCode;//冲红操作验证码
	private String remark;//入库备注说明
	 
	public StoreInventoryIn() {
	}

	public StoreInventoryIn(Long id){
		this();
		this.id = id;
	}
	@Column(name="ID")
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="STORE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public Store getStore() {
		return store;
	}

	public void setStore(Store store) {
		this.store = store;
	}


	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="EMPLOYEE_ID", nullable=false)
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	
	@Column(name="STATUS")
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
 
	@Column(name="IN_PRODUCT_CHANNEL")
	public int getInProductChannel() {
		return inProductChannel;
	}

	public void setInProductChannel(int inProductChannel) {
		this.inProductChannel = inProductChannel;
	}
	@Column(name="CANCEL_CODE")
	public String getCalcelCode() {
		return calcelCode;
	}

	public void setCalcelCode(String calcelCode) {
		this.calcelCode = calcelCode;
	}
	
	@Column(name="REMARK")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	@Column(name="IN_TIME")
	public Date getInDate() {
		return inDate;
	}

	public void setInDate(Date inDate) {
		this.inDate = inDate;
	}

	public int getAmount() {
		return amount;
	}

	public void setAmount(int amount) {
		this.amount = amount;
	}
}


